import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// 导入api接口
import api from './api'
// 按需引入 vant
import {
  Swipe, SwipeItem, Lazyload, Button, ActionSheet, Field, Uploader,
  Checkbox, Radio, RadioGroup, Icon, Toast, Dialog, Popup, Picker, Overlay,
  Calendar, Tab, Tabs,NavBar,Loading ,Skeleton,CountDown,Image ,ImagePreview,Rate,Form,CheckboxGroup,
  SubmitBar ,Collapse, CollapseItem,Cell,CellGroup 
} from "vant";
// 重置 vant 样式
import "../src/assets/css/resetui.less";
//import VConsole from 'vconsole'

// 动态title
import VueWechatTitle from 'vue-wechat-title'
/* 
if (process.env.NODE_ENV === 'production') {
  new VConsole()
} */

Vue.prototype.$api = api; // 将api挂载到vue的原型上

Vue.use(Swipe).use(VueWechatTitle)
  .use(SwipeItem)
  .use(Lazyload).use(Button).use(ActionSheet).use(Field).use(Uploader)
  .use(Checkbox).use(Radio).use(RadioGroup).use(Icon).use(Toast).use(Dialog)
  .use(Popup).use(Picker).use(Overlay).use(Calendar).use(Tab).use(Tabs).use(NavBar)
  .use(Loading).use(Skeleton).use(CountDown).use(Image).use(ImagePreview).use(Rate)
  .use(Form).use(CheckboxGroup).use(SubmitBar).use(Collapse).use(CollapseItem).use(CellGroup)
  .use(Cell)


// 将所有 loading Toast 设置为背景不可点击 (2.2.10 版本开始支持)
Toast.setDefaultOptions('loading', { forbidClick: true });
Toast.setDefaultOptions({ duration: 3000 });
Vue.config.productionTip = false;
//百度统计
// eslint-disable-next-line
const _hmt = _hmt || [];
// eslint-disable-next-line
window._hmt = _hmt; // 必须把_hmt挂载到window下，否则找不到
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?9bca6a0c31219457e4830468f4add292";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
router.beforeEach((to, from, next) => {
  // eslint-disable-next-line
  if (_hmt) {
    if (to.path) {
      // eslint-disable-next-line
      _hmt.push(['_trackPageview', to.fullPath]);
    }
  }
  next();
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
